package com.kgc.storeprovider.service.impl;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.OutStoreDetail;
import com.kgc.store.pojo.QualityDetail;
import com.kgc.storeprovider.dao.QualityDetailMapper;
import com.kgc.storeprovider.dao.QualityMapper;
import com.kgc.storeprovider.service.QualityDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class QualityDetailServiceImpl implements QualityDetailService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private QualityDetailMapper qualityDetailMapper;

    @Override
    public ResponseMsg getQualityDetailList(String qualityCode) {
        logger.info("QualityDetailServiceImpl getQualityDetailList qualityCode:"+qualityCode);
        ResponseMsg msg = new ResponseMsg();
        List<QualityDetail> qualityDetailList = qualityDetailMapper.getQualityDetailList(qualityCode);
        logger.debug("QualityDetailServiceImpl getQualityDetailList qualityCode:"+qualityCode);
        msg.setCode("200");
        msg.setData(qualityDetailList);
        logger.debug("QualityDetailServiceImpl getQualityDetailList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delQualityDetailByQualityCode(String qualityCode) {
        ResponseMsg msg = new ResponseMsg();
        int delCount = qualityDetailMapper.delQualityDetailByQualityCode(qualityCode);
        if(delCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }

    @Override
    public ResponseMsg addQualityDetail(QualityDetail qualityDetail) {
        ResponseMsg msg = new ResponseMsg();
        int insertCount = qualityDetailMapper.addQualityDetail(qualityDetail);
        if(insertCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }


}
